Display of source code information in a tree structure is an easy method for obtaining an overview of the source code. Such a display is created by first parsing the source code to extract relevant information and then analyzing the information to structure the display.
Display of source code information to a user must take into consideration various aspects regarding the parsing of the source code and its eventual display. The depth of parsing affects the performance of a parser. Different granularity levels, or depths, of parsing result in a different amount of information being produced for display. Coarse grained parsing may, for example, produce information about the different classes in a set of object oriented source code, as well as information about their relationships with one another. Medium grained parsing may parse the body and get a list of variables and methods for each class. Finer grained parsing may gather information such as statements, expressions, declarations and type specifiers allowing more detailed information about the type, source, and uses for variables and methods. As the granularity of the parsing decreases (i.e. from coarse grained to finer grained) there is an increase in the amount of information that is extracted from the source code and the amount of analysis required to format the information for display. With the increase in information and analysis comes an increase in processing power and time required to perform the parsing.
The degree to which a parser tolerates errors is another important consideration during design of the parser. With decreasing granularity of a parser there is a corresponding decrease to error tolerance. The more information a parser gathers the more likely it is that errors will adversely affect the gathering of information since simple syntactical errors cannot be as easily skipped with a decreased parsing granularity. For parsers using only a single granularity a simple syntactical error at a low level (e.g. an incomplete variable definition) will adversely affect parsing and display of higher level information (e.g. function definitions).
Another consideration for a parser is how the information determined from the source code is stored, thus the basic structure of the tree that is created from the source code information is considered.
Traditionally parsers are classified in according to the granularity level at which the parser operates. Three exemplary granularity levels are coarse, medium and fine. Coarse parsing works at the highest level gathering summary information about a source code file. Medium parsing involves examining the different components of each source code file (e.g. functions, classes, etc.) and summarizing these components. Fine parsing gathers a detailed summary about different elements (e.g. variables names, etc.) in each component in a source code file.